﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Demo.Business;
using Niknak.Social.Twitter;

namespace Demo
{
    class Program
    {
        private static void ProcessTweet(object context, Niknak.Social.Twitter.Streams.Public.Statuses<TwitterConfig, object>.StreamStatus status, IMessage twitterMessage)
        {
            if (status == Niknak.Social.Twitter.Streams.Public.Statuses<TwitterConfig, object>.StreamStatus.OK)
                Console.WriteLine(twitterMessage.Text);
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Loading tweets...\n\n");

            //using (Niknak.Social.Twitter.Streams.Public.Statuses<TwitterConfig, object> statusesStream = new Niknak.Social.Twitter.Streams.Public.Statuses<TwitterConfig, object>(ProcessTweet, null))
            //{
            //    //statusesStream.FilterByKeywords<TwitterMessage, TwitterUser, TwitterMedia, TwitterMediaSize>("#nowplaying,#myteachersays");
            //    statusesStream.FilterByUsers<TwitterMessage, TwitterUser, TwitterMedia, TwitterMediaSize>("1117122236");
            //    //statusesStream.FilterByLocations<TwitterMessage, TwitterUser, TwitterMedia, TwitterMediaSize>("-122.75,36.8,-121.75,37.8");

            //    Thread.Sleep(80000);
            //    Console.WriteLine("We're done here");
            //}

            
            ////facebook shizzle
            //string postId = "10151746890235772";
            //int pageSize = 100;
            //Niknak.Social.Facebook.Likes.LikesData likesData = Niknak.Social.Facebook.Likes.GetPostLikes(postId, pageSize);

            //do
            //{
            //    foreach (KeyValuePair<string, string> user in likesData.Users)
            //        Console.WriteLine(user.Key + " " + user.Value);

            //    if (!likesData.EndOfStream)
            //        likesData = Niknak.Social.Facebook.Likes.GetPostLikes(postId, pageSize, likesData.AfterCursor);
            //} while (!likesData.EndOfStream);


            ////testing posting
            //string message = "@2020Developers hello world reply, from the code's and stuff!";
            //string replyTo = "293765834919276544";

            //UserTimeline<TwitterConfig>.PostUpdate(message, replyTo);

            string screenName = "JWDevs";
            int count = 20;                     //defaults to 10
            bool includeRTs = false;            //defaults to false
            string sinceMessageId = "1";        //defaults to "1"

            //List<Message> basicTweets = Search<TwitterConfig>.GetTweets
            //    (
            //        "#hashbrag",
            //        count,
            //        "mixed",
            //        sinceMessageId
            //    );

            //foreach (Message tweet in basicTweets)
            //    Console.WriteLine(tweet.Text + "\n\n");

            //basic
            List<Message> basicTweets = UserTimeline<TwitterConfig>.GetTweets
                (
                    screenName,
                    count,
                    includeRTs,
                    sinceMessageId
                );

            foreach (Message tweet in basicTweets)
                Console.WriteLine(tweet.Text + "\n\n");

            ////semi custom
            //List<TwitterMessage> semiCustomTweets = UserTimeline<TwitterConfig>.GetTweets<TwitterMessage, TwitterUser>
            //    (
            //        screenName,
            //        count,
            //        includeRTs,
            //        sinceMessageId
            //    );

            //foreach (TwitterMessage tweet in semiCustomTweets)
            //    Console.WriteLine(tweet.Text + "\n\n");

            ////fully custom
            //List<TwitterMessage> customTweets = UserTimeline<TwitterConfig>.GetTweets<TwitterMessage, TwitterUser, TwitterMedia, TwitterMediaSize>
            //    (
            //        screenName,
            //        count,
            //        includeRTs,
            //        sinceMessageId
            //    );

            //foreach (TwitterMessage tweet in customTweets)
            //    Console.WriteLine(tweet.Text + "\n\n");

            Console.ReadKey();
        }
    }
}
